55 produces<ValueMap<DeDxData> >();
58 string estimatorName = iConfig.
getParameter<
string>(
"estimator");
72 MeVperADCPixel = iConfig.
getParameter<
double>(
"MeVperADCPixel");
73 MeVperADCStrip = iConfig.
getParameter<
double>(
"MeVperADCStrip");
76 useCalibration = iConfig.
getParameter<
bool>(
"UseCalibration");
77 m_calibrationPath = iConfig.
getParameter<
string>(
"calibrationPath");
79 if(!usePixel && !useStrip)
80 edm::LogWarning(
"DeDxHitsProducer") <<
"Pixel Hits AND Strip Hits will not be used to estimate dEdx --> BUG, Please Update the config file";
94 if(MODsColl.size()!=0)
return;
100 vector<GeomDet*>
Det = tkGeom->dets();
101 for(
unsigned int i=0;
i<Det.size();
i++){
102 DetId Detid = Det[
i]->geographicalId();
107 double Thick=-1, Dist=-1, Norma=-1;
111 Norma = MeVperADCStrip/Thick;
112 }
else if(PixelDetUnit){
115 Norma = MeVperADCPixel/Thick;
124 MODsColl[MOD->
DetId] = MOD;
127 MakeCalibrationMap();
144 iEvent.
getByLabel(m_trajTrackAssociationTag, trajTrackAssociationHandle);
148 iEvent.
getByLabel(m_tracksTag,trackCollectionHandle);
150 size_t n = TrajToTrackMap.
size();
151 std::vector<DeDxData> dedxEstimate(n);
161 vector<DeDxTools::RawHits> hits;
164 const vector<TrajectoryMeasurement> & measurements = traj->measurements();
165 for(vector<TrajectoryMeasurement>::const_iterator it = measurements.begin(); it!=measurements.end(); it++){
167 if( !trajState.
isValid())
continue;
171 double cosine = trackDirection.
z()/trackDirection.
mag();
174 if(!useStrip)
continue;
181 mono.
charge = getCharge((matchedHit->monoHit()->cluster()).
get(),mono.
NSaturating);
182 stereo.
charge = getCharge((matchedHit->stereoHit()->cluster()).
get(),stereo.
NSaturating);
184 mono.
detId= matchedHit->monoHit()->geographicalId();
185 stereo.
detId= matchedHit->stereoHit()->geographicalId();
187 if(shapetest && !(
DeDxTools::shapeSelection(((matchedHit->stereoHit()->cluster()).
get())->amplitudes()))) hits.push_back(stereo);
188 if(shapetest && !(
DeDxTools::shapeSelection(((matchedHit->monoHit ()->cluster()).
get())->amplitudes()))) hits.push_back(mono);
190 if(!useStrip)
continue;
199 hits.push_back(mono);
200 }
else if(
const SiStripRecHit2D* singleHit=dynamic_cast<const SiStripRecHit2D*>(recHit)){
201 if(!useStrip)
continue;
207 mono.
detId= singleHit->geographicalId();
209 hits.push_back(mono);
210 }
else if(
const SiStripRecHit1D* single1DHit=dynamic_cast<const SiStripRecHit1D*>(recHit)){
211 if(!useStrip)
continue;
217 mono.
detId= single1DHit->geographicalId();
219 hits.push_back(mono);
220 }
else if(
const SiPixelRecHit* pixelHit=dynamic_cast<const SiPixelRecHit*>(recHit)){
221 if(!usePixel)
continue;
227 pixel.
charge = pixelHit->cluster()->charge();
229 pixel.
detId= pixelHit->geographicalId();
230 hits.push_back(pixel);
235 int NClusterSaturating = 0;
236 for(
size_t i=0;
i < hits.size();
i++)
241 dedxHits.push_back(
DeDxHit( charge, MOD->
Distance, pathLen, hits[
i].detId) );
243 if(hits[i].NSaturating>0)NClusterSaturating++;
246 sort(dedxHits.begin(),dedxHits.end(),less<DeDxHit>());
247 std::pair<float,float> val_and_error = m_estimator->dedx(dedxHits);
251 val_and_error.second = NClusterSaturating;
253 dedxEstimate[
j] =
DeDxData(val_and_error.first, val_and_error.second, dedxHits.size() );
255 filler.
insert(trackCollectionHandle, dedxEstimate.begin(), dedxEstimate.end());
260 iEvent.
put(trackDeDxEstimateAssociation);
267 if(!useCalibration)
return;
269 TChain* t1 =
new TChain(
"SiStripCalib/APVGain");
270 t1->Add(m_calibrationPath.c_str());
272 unsigned int tree_DetId;
273 unsigned char tree_APVId;
276 t1->SetBranchAddress(
"DetId" ,&tree_DetId );
277 t1->SetBranchAddress(
"APVId" ,&tree_APVId );
278 t1->SetBranchAddress(
"Gain" ,&tree_Gain );
282 for (
unsigned int ientry = 0; ientry < t1->GetEntries(); ientry++) {
283 t1->GetEntry(ientry);
285 MOD->
Gain = tree_Gain;
295 const vector<uint8_t>& Ampls = Cluster->
amplitudes();
301 Saturating_Strips = 0;
302 for(
unsigned int i=0;
i<Ampls.size();
i++){
303 int CalibratedCharge = Ampls[
i];
308 CalibratedCharge = (int)(CalibratedCharge / MOD->
Gain );
309 if(CalibratedCharge>=1024){
310 CalibratedCharge = 255;
311 }
else if(CalibratedCharge>=255){
312 CalibratedCharge = 254;
316 toReturn+=CalibratedCharge;
317 if(CalibratedCharge>=254)Saturating_Strips++;
T getParameter(std::string const &) const
DeDxEstimatorProducer(const edm::ParameterSet &)
T getUntrackedParameter(std::string const &, T const &) const
const_iterator end() const
last iterator over the map (read only)
LocalVector localDirection() const
void insert(const H &h, I begin, I end)
std::vector< DeDxHit > DeDxHitCollection
uint32_t geographicalId() const
uint32_t rawId() const
get the raw id
virtual float thickness() const =0
const Surface::PositionType & position() const
The position (origin of the R.F.)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
int getCharge(const SiStripCluster *Cluster, int &Saturating_Strips)
virtual void beginRun(edm::Run &run, const edm::EventSetup &)
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
void MakeCalibrationMap()
DEFINE_FWK_MODULE(CosmicTrackingParticleSelector)
const Bounds & bounds() const
size_type size() const
map size
ClusterRef const & cluster() const
key_type key() const
Accessor for product key.
virtual void produce(edm::Event &, const edm::EventSetup &)
T const * product() const
const_iterator begin() const
first iterator over the map (read only)
DetId geographicalId() const
virtual const BoundPlane & surface() const
The nominal surface of the GeomDet.
const std::vector< uint8_t > & amplitudes() const