CMS 3D CMS Logo

List of all members | Public Member Functions | Private Types | Private Attributes | Static Private Attributes
AlignmentStats Class Reference

#include <AlignmentStats.h>

Inheritance diagram for AlignmentStats:
edm::EDAnalyzer edm::EDConsumerBase

Public Member Functions

 AlignmentStats (const edm::ParameterSet &iConfig)
 
void analyze (const edm::Event &iEvent, const edm::EventSetup &iSetup) override
 
void beginJob () override
 
void endJob () override
 
 ~AlignmentStats () override
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
 ~EDAnalyzer () override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Types

typedef std::map< uint32_t, uint32_t > DetHitMap
 

Private Attributes

float Chi2n [MAXTRKS_]
 
float Eta [MAXTRKS_]
 
int event_
 
DetHitMap hitmap_
 
std::string hitsTreeName_
 
bool keepHitPopulation_
 
bool keepTrackStats_
 
int Nhits [MAXTRKS_][7]
 
unsigned int ntracks
 
TTree * outtree_
 
edm::InputTag overlapAM_
 
DetHitMap overlapmap_
 
float P [MAXTRKS_]
 
float Phi [MAXTRKS_]
 
uint32_t prescale_
 
float Pt [MAXTRKS_]
 
int run_
 
edm::InputTag src_
 
std::string statsTreeName_
 
uint32_t tmpPresc_
 
const TrackerGeometrytrackerGeometry_
 
const TrackerTopologytrackerTopology_
 
TFile * treefile_
 

Static Private Attributes

static const int MAXTRKS_ =200
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Definition at line 29 of file AlignmentStats.h.

Member Typedef Documentation

typedef std::map<uint32_t,uint32_t> AlignmentStats::DetHitMap
private

Definition at line 61 of file AlignmentStats.h.

Constructor & Destructor Documentation

AlignmentStats::AlignmentStats ( const edm::ParameterSet iConfig)

Definition at line 27 of file AlignmentStats.cc.

References outtree_.

27  :
28  src_(iConfig.getParameter<edm::InputTag>("src")),
29  overlapAM_(iConfig.getParameter<edm::InputTag>("OverlapAssoMap")),
30  keepTrackStats_(iConfig.getParameter<bool>("keepTrackStats")),
31  keepHitPopulation_(iConfig.getParameter<bool>("keepHitStats")),
32  statsTreeName_(iConfig.getParameter<string>("TrkStatsFileName")),
33  hitsTreeName_(iConfig.getParameter<string>("HitStatsFileName")),
34  prescale_(iConfig.getParameter<uint32_t>("TrkStatsPrescale"))
35 {
36 
37  //sanity checks
38 
39  //init
40  outtree_=nullptr;
41 
42 }//end constructor
T getParameter(std::string const &) const
uint32_t prescale_
edm::InputTag src_
std::string statsTreeName_
std::string hitsTreeName_
edm::InputTag overlapAM_
AlignmentStats::~AlignmentStats ( )
override

Definition at line 44 of file AlignmentStats.cc.

44  {
45  //
46 }

Member Function Documentation

void AlignmentStats::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
)
override

Definition at line 83 of file AlignmentStats.cc.

References Chi2n, className(), SiStripRecHit1D::cluster(), SiStripRecHit2D::cluster(), SiPixelRecHit::cluster(), Eta, edm::EventID::event(), event_, Exception, edm::EventSetup::get(), edm::Event::getByLabel(), hitmap_, edm::EventBase::id(), AlignmentClusterFlag::isOverlap(), gen::k, MAXTRKS_, Nhits, ntracks, outtree_, overlapAM_, overlapmap_, Phi, PixelSubdetector::PixelBarrel, PixelSubdetector::PixelEndcap, prescale_, edm::ESHandle< T >::product(), Pt, edm::EventID::run(), run_, src_, DetId::subdetId(), SiStripDetId::TEC, SiStripDetId::TIB, SiStripDetId::TID, tmpPresc_, SiStripDetId::TOB, trackerGeometry_, trackerTopology_, and gather_cfg::Tracks.

83  {
84 
85  //load list of detunits needed then in endJob
86 
87  edm::ESHandle<TrackerGeometry> tmpTkGeometry;
88  iSetup.get<TrackerDigiGeometryRecord>().get(tmpTkGeometry);
89  trackerGeometry_=&(*tmpTkGeometry);
90 
92  iSetup.get<TrackerTopologyRcd>().get(tTopoHandle);
93  trackerTopology_ = tTopoHandle.product();
94 
95  //take trajectories and tracks to loop on
96  // edm::Handle<TrajTrackAssociationCollection> TrackAssoMap;
98  iEvent.getByLabel(src_, Tracks);
99 
100  //take overlap HitAssomap
102  iEvent.getByLabel(overlapAM_, hMap);
103  const AliClusterValueMap &OverlapMap=*hMap;
104 
105  // Initialise
106  run_=1;
107  event_=1;
108  ntracks=0;
109  run_=iEvent.id().run();
110  event_=iEvent.id().event();
111  ntracks=Tracks->size();
112  // if(ntracks>1) std::cout<<"~~~~~~~~~~~~\n For this event processing "<<ntracks<<" tracks"<<std::endl;
113 
114  unsigned int trk_cnt=0;
115 
116  for(int j=0;j<MAXTRKS_;j++){
117  Eta[j]=-9999.0;
118  Phi[j]=-8888.0;
119  P[j] =-7777.0;
120  Pt[j] =-6666.0;
121  Chi2n[j]=-2222.0;
122  for(int k=0;k<7;k++){
123  Nhits[j][k]=0;
124  }
125  }
126 
127  // int npxbhits=0;
128 
129  //loop on tracks
130  for(std::vector<reco::Track>::const_iterator ittrk = Tracks->begin(), edtrk = Tracks->end(); ittrk != edtrk; ++ittrk){
131  Eta[trk_cnt]=ittrk->eta();
132  Phi[trk_cnt]=ittrk->phi();
133  Chi2n[trk_cnt]=ittrk->normalizedChi2();
134  P[trk_cnt]=ittrk->p();
135  Pt[trk_cnt]=ittrk->pt();
136  Nhits[trk_cnt][0]=ittrk->numberOfValidHits();
137 
138  // if(ntracks>1)std::cout<<"Track #"<<trk_cnt+1<<" params: Eta="<< Eta[trk_cnt]<<" Phi="<< Phi[trk_cnt]<<" P="<<P[trk_cnt]<<" Nhits="<<Nhits[trk_cnt][0]<<std::endl;
139 
140  int nhit=0;
141  //loop on tracking rechits
142  //std::cout << " loop on hits of track #" << (itt - tracks->begin()) << std::endl;
143  for (auto const& hit : ittrk->recHits())
144  {
145  if(! hit->isValid())continue;
146  DetId detid = hit->geographicalId();
147  int subDet = detid.subdetId();
148  uint32_t rawId = hit->geographicalId().rawId();
149 
150  // if(subDet==1)npxbhits++;
151 
152  //look if you find this detid in the map
153  DetHitMap::iterator mapiter;
154  mapiter= hitmap_.find(rawId);
155  if(mapiter!=hitmap_.end() ){//present, increase its value by one
156  // hitmap_[rawId]=hitmap_[rawId]+1;
157  ++(hitmap_[rawId]);
158  }
159  else{//not present, let's add this key to the map with value=1
160  hitmap_.insert(pair<uint32_t, uint32_t>(rawId, 1));
161  }
162 
163  AlignmentClusterFlag inval;
164 
165  bool hitInPixel= (subDet==PixelSubdetector::PixelBarrel)||(subDet==PixelSubdetector::PixelEndcap);
166  bool hitInStrip=(subDet==SiStripDetId::TIB) || (subDet==SiStripDetId::TID) ||(subDet==SiStripDetId::TOB) ||(subDet==SiStripDetId::TEC);
167 
168  if(!(hitInPixel||hitInStrip)){
169  //skip only this hit, don't stop everything throwing an exception
170  edm::LogError("AlignmentStats")<<"Hit not belonging neither to pixels nor to strips! Skipping it. SubDet= "<<subDet;
171  continue;
172  }
173 
174  //check also if the hit is an overlap. If yes fill a dedicated hitmap
175  if (hitInStrip){
176  const std::type_info &type = typeid(*hit);
177 
178  if (type == typeid(SiStripRecHit1D)) {
179  //Notice the difference respect to when one loops on Trajectories: the recHit is a TrackingRecHit and not a TransientTrackingRecHit
180  const SiStripRecHit1D* striphit=dynamic_cast<const SiStripRecHit1D*>(hit);
181  if(striphit!=nullptr){
182  SiStripRecHit1D::ClusterRef stripclust(striphit->cluster());
183  inval = OverlapMap[stripclust];
184  }
185  else{
186  // edm::LogError("AlignmentStats")<<"ERROR in <AlignmentStats::analyze>: Dynamic cast of Strip RecHit1D failed! TypeId of the RecHit: "<<className(*hit);
187  throw cms::Exception("NullPointerError")<<"ERROR in <AlignmentStats::analyze>: Dynamic cast of Strip RecHit1D failed! TypeId of the RecHit: "<<className(*hit);
188  }
189  }//end if sistriprechit1D
190  if (type == typeid(SiStripRecHit2D)) {
191  const SiStripRecHit2D* striphit=dynamic_cast<const SiStripRecHit2D*>(hit);
192  if(striphit!=nullptr){
193  SiStripRecHit2D::ClusterRef stripclust(striphit->cluster());
194  inval = OverlapMap[stripclust];
195  //cout<<"Taken the Strip Cluster with ProdId "<<stripclust.id() <<"; the Value in the map is "<<inval<<" (DetId is "<<hit->geographicalId().rawId()<<")"<<endl;
196  }
197  else{
198  throw cms::Exception("NullPointerError")<<"ERROR in <AlignmentStats::analyze>: Dynamic cast of Strip RecHit2D failed! TypeId of the RecHit: "<<className(*hit);
199  // edm::LogError("AlignmentStats")<<"ERROR in <AlignmentStats::analyze>: Dynamic cast of Strip RecHit2D failed! TypeId of the RecHit: "<<className(*hit);
200  }
201  }//end if sistriprechit2D
202 
203  }//end if hit in Strips
204  else{
205  const SiPixelRecHit* pixelhit= dynamic_cast<const SiPixelRecHit*>(hit);
206  if(pixelhit!=nullptr){
207  SiPixelClusterRefNew pixclust(pixelhit->cluster());
208  inval = OverlapMap[pixclust];
209  //cout<<"Taken the Pixel Cluster with ProdId "<<pixclust.id() <<"; the Value in the map is "<<inval<<" (DetId is "<<hit->geographicalId().rawId()<<")"<<endl;
210  }
211  else{
212  edm::LogError("AlignmentStats")<<"ERROR in <AlignmentStats::analyze>: Dynamic cast of Pixel RecHit failed! TypeId of the RecHit: "<<className(*hit);
213  }
214  }//end else hit is in Pixel
215 
216 
217  bool isOverlapHit(inval.isOverlap());
218 
219  if( isOverlapHit ){
220  //cout<<"This hit is an overlap !"<<endl;
221  DetHitMap::iterator overlapiter;
222  overlapiter=overlapmap_.find(rawId);
223 
224  if(overlapiter!=overlapmap_.end() ){//the det already collected at least an overlap, increase its value by one
225  overlapmap_[rawId]=overlapmap_[rawId]+1;
226  }
227  else{//first overlap on det unit, let's add it to the map
228  overlapmap_.insert(pair<uint32_t, uint32_t>(rawId, 1));
229  }
230  }//end if the hit is an overlap
231 
232 
233 
234 
235  int subdethit= static_cast<int>(hit->geographicalId().subdetId());
236  // if(ntracks>1)std::cout<<"Hit in SubDet="<<subdethit<<std::endl;
237  Nhits[trk_cnt][subdethit]=Nhits[trk_cnt][subdethit]+1;
238  nhit++;
239  }//end loop on trackingrechits
240  trk_cnt++;
241 
242  }//end loop on tracks
243 
244  // cout<<"Total number of pixel hits is "<<npxbhits<<endl;
245 
246  tmpPresc_--;
247  if(tmpPresc_<1){
248  outtree_->Fill();
250  }
251  if(trk_cnt!=ntracks)edm::LogError("AlignmentStats")<<"\nERROR! trk_cnt="<<trk_cnt<<" ntracks="<<ntracks;
252 
253  return;
254 }
RunNumber_t run() const
Definition: EventID.h:39
ClusterRef cluster() const
float Eta[MAXTRKS_]
type
Definition: HCALResponse.h:21
EventNumber_t event() const
Definition: EventID.h:41
uint32_t prescale_
DetHitMap hitmap_
edm::InputTag src_
DetHitMap overlapmap_
const TrackerTopology * trackerTopology_
float Chi2n[MAXTRKS_]
uint32_t tmpPresc_
float Phi[MAXTRKS_]
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:41
ClusterRef cluster() const
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:480
int k[5][pyjets_maxn]
Definition: DetId.h:18
const TrackerGeometry * trackerGeometry_
ClusterRef cluster() const
Definition: SiPixelRecHit.h:49
static const int MAXTRKS_
std::pair< OmniClusterRef, TrackingParticleRef > P
unsigned int ntracks
edm::EventID id() const
Definition: EventBase.h:59
int Nhits[MAXTRKS_][7]
float Pt[MAXTRKS_]
T get() const
Definition: EventSetup.h:71
edm::InputTag overlapAM_
T const * product() const
Definition: ESHandle.h:86
std::string className(const T &t)
Definition: ClassName.h:30
Our base class.
Definition: SiPixelRecHit.h:23
void AlignmentStats::beginJob ( void  )
overridevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 48 of file AlignmentStats.cc.

References Chi2n, Eta, event_, Nhits, ntracks, outtree_, Phi, prescale_, Pt, run_, statsTreeName_, tmpPresc_, and treefile_.

48  {// const edm::EventSetup &iSetup
49 
50  //book track stats tree
51  treefile_=new TFile(statsTreeName_.c_str(),"RECREATE");
52  treefile_->cd();
53  outtree_=new TTree("AlignmentTrackStats","Statistics of Tracks used for Alignment");
54  // int nHitsinPXB[MAXTRKS_], nHitsinPXE[MAXTRKS_], nHitsinTEC[MAXTRKS_], nHitsinTIB[MAXTRKS_],nHitsinTOB[MAXTRKS_],nHitsinTID[MAXTRKS_];
55 
56 
57  outtree_->Branch("Ntracks" ,&ntracks ,"Ntracks/i");
58  outtree_->Branch("Run_" ,&run_ ,"Run_Nr/I");
59  outtree_->Branch("Event" ,&event_ ,"EventNr/I");
60  outtree_->Branch("Eta" ,&Eta ,"Eta[Ntracks]/F");
61  outtree_->Branch("Phi" ,&Phi ,"Phi[Ntracks]/F");
62  outtree_->Branch("P" ,&P ,"P[Ntracks]/F");
63  outtree_->Branch("Pt" ,&Pt ,"Pt[Ntracks]/F");
64  outtree_->Branch("Chi2n" ,&Chi2n ,"Chi2n[Ntracks]/F");
65  outtree_->Branch("Nhits" ,&Nhits ,"Nhits[Ntracks][7]/I");
66  /*
67  outtree_->Branch("NhitsPXB" , ,);
68  outtree_->Branch("NhitsPXE" , ,);
69  outtree_->Branch("NhitsTIB" , ,);
70  outtree_->Branch("NhitsTID" , ,);
71  outtree_->Branch("NhitsTOB" , ,);
72  outtree_->Branch("NhitsTOB" , ,);
73  */
74 
76 
77  //load the tracker geometry from the EventSetup
78  // iSetup.get<TrackerDigiGeometryRecord>().get(trackerGeometry_);
79 
80 }//end beginJob
float Eta[MAXTRKS_]
uint32_t prescale_
float Chi2n[MAXTRKS_]
uint32_t tmpPresc_
float Phi[MAXTRKS_]
std::string statsTreeName_
std::pair< OmniClusterRef, TrackingParticleRef > P
unsigned int ntracks
int Nhits[MAXTRKS_][7]
float Pt[MAXTRKS_]
void AlignmentStats::endJob ( void  )
overridevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 256 of file AlignmentStats.cc.

References DEFINE_FWK_MODULE, PV3DBase< T, PVType, FrameType >::eta(), hitmap_, hitsTreeName_, triggerObjects_cff::id, fastTrackerRecHitType::is2D(), nhits, outtree_, overlapmap_, PV3DBase< T, PVType, FrameType >::perp(), PV3DBase< T, PVType, FrameType >::phi(), PixelSubdetector::PixelBarrel, PixelSubdetector::PixelEndcap, RecoTauValidation_cfi::posX, RecoTauValidation_cfi::posY, TrackerTopology::pxbLayer(), TrackerTopology::pxfDisk(), DetId::subdetId(), SiStripDetId::TEC, TrackerTopology::tecIsDoubleSide(), TrackerTopology::tecIsStereo(), TrackerTopology::tecWheel(), SiStripDetId::TIB, TrackerTopology::tibIsDoubleSide(), TrackerTopology::tibIsStereo(), TrackerTopology::tibLayer(), SiStripDetId::TID, TrackerTopology::tidIsDoubleSide(), TrackerTopology::tidIsStereo(), TrackerTopology::tidWheel(), SiStripDetId::TOB, TrackerTopology::tobIsDoubleSide(), TrackerTopology::tobIsStereo(), TrackerTopology::tobLayer(), trackerTopology_, and treefile_.

Referenced by o2olib.O2ORunMgr::executeJob().

256  {
257 
258  treefile_->cd();
259  edm::LogInfo("AlignmentStats")<<"Writing out the TrackStatistics in "<<gDirectory->GetPath()<<std::endl;
260  outtree_->Write();
261  delete outtree_;
262 
263  //create tree with hit maps (hitstree)
264  //book track stats tree
265  TFile *hitsfile=new TFile(hitsTreeName_.c_str(),"RECREATE");
266  hitsfile->cd();
267  TTree *hitstree=new TTree("AlignmentHitMap","Maps of Hits used for Alignment");
268 
269  unsigned int id=0,nhits=0,noverlaps=0;
270  float posX(-99999.0),posY(-77777.0),posZ(-88888.0);
271  float posEta(-6666.0),posPhi(-5555.0),posR(-4444.0);
272  int subdet=0;
273  unsigned int layer=0;
274  bool is2D=false,isStereo=false;
275  hitstree->Branch("DetId", &id , "DetId/i");
276  hitstree->Branch("Nhits", &nhits , "Nhits/i");
277  hitstree->Branch("Noverlaps",&noverlaps,"Noverlaps/i");
278  hitstree->Branch("SubDet", &subdet, "SubDet/I");
279  hitstree->Branch("Layer", &layer, "Layer/i");
280  hitstree->Branch("is2D" , &is2D, "is2D/B");
281  hitstree->Branch("isStereo", &isStereo, "isStereo/B");
282  hitstree->Branch("posX", &posX, "posX/F");
283  hitstree->Branch("posY", &posY, "posY/F");
284  hitstree->Branch("posZ", &posZ, "posZ/F");
285  hitstree->Branch("posR", &posR, "posR/F");
286  hitstree->Branch("posEta", &posEta, "posEta/F");
287  hitstree->Branch("posPhi", &posPhi, "posPhi/F");
288 
289  /*
290  TTree *overlapstree=new TTree("OverlapHitMap","Maps of Overlaps used for Alignment");
291  hitstree->Branch("DetId", &id , "DetId/i");
292  hitstree->Branch("NOverlaps", &nhits , "Nhits/i");
293  hitstree->Branch("SubDet", &subdet, "SubDet/I");
294  hitstree->Branch("Layer", &layer, "Layer/i");
295  hitstree->Branch("is2D" , &is2D, "is2D/B");
296  hitstree->Branch("isStereo",&isStereo,"isStereo/B");
297  hitstree->Branch("posX", &posX, "posX/F");
298  hitstree->Branch("posY", &posY, "posY/F");
299  hitstree->Branch("posZ", &posZ, "posZ/F");
300  hitstree->Branch("posR", &posR, "posR/F");
301  hitstree->Branch("posEta", &posEta, "posEta/F");
302  hitstree->Branch("posPhi", &posPhi, "posPhi/F");
303  */
304 
305  std::unique_ptr<AlignableTracker> theAliTracker=std::make_unique<AlignableTracker>(&(*trackerGeometry_), trackerTopology_);
306  const auto& Detunitslist = theAliTracker->deepComponents();
307  int ndetunits=Detunitslist.size();
308  edm::LogInfo("AlignmentStats")<<"Number of DetUnits in the AlignableTracker: "<< ndetunits<<std::endl;
309 
310  for(int det_cnt=0;det_cnt< ndetunits;++det_cnt){
311 
312  //re-initialize for safety
313  id=0;
314  nhits=0;
315  noverlaps=0;
316  posX=-99999.0;
317  posY=-77777.0;
318  posZ=-88888.0;
319  posEta=-6666.0;
320  posPhi=-5555.0;
321  posR=-4444.0;
322  subdet=0;
323  layer=0;
324  is2D=false;
325  isStereo=false;
326 
327  //if detunit in vector is found also in the map, look for how many hits were collected
328  //and save in the tree this number
329  id=static_cast <uint32_t>( Detunitslist[det_cnt]->id() );
330  if( hitmap_.find(id) != hitmap_.end() ){
331  nhits=hitmap_[id];
332  }
333  //if not, save nhits=0
334  else{
335  nhits=0;
336  hitmap_.insert(pair<uint32_t, uint32_t>(id, 0));
337  }
338 
339  if( overlapmap_.find(id) != overlapmap_.end() ){
340  noverlaps=overlapmap_[id];
341  }
342  //if not, save nhits=0
343  else{
344  noverlaps=0;
345  overlapmap_.insert(pair<uint32_t, uint32_t>(id, 0));
346  }
347 
348  //take other geometrical infos from the det
349  posX= Detunitslist[det_cnt]->globalPosition().x();
350  posY= Detunitslist[det_cnt]->globalPosition().y();
351  posZ= Detunitslist[det_cnt]->globalPosition().z();
352 
353  align::GlobalVector vec(posX,posY,posZ);
354  posR = vec.perp();
355  posPhi = vec.phi();
356  posEta = vec.eta();
357  // posPhi = atan2(posY,posX);
358 
359  DetId detid(id);
360  subdet=detid.subdetId();
361 
362  //get layers, petals, etc...
363  if(subdet==PixelSubdetector::PixelBarrel){//PXB
364 
365  layer=trackerTopology_->pxbLayer(id);
366  is2D=true;
367  isStereo=false;
368  }
369  else if(subdet==PixelSubdetector::PixelEndcap){
370 
371  layer=trackerTopology_->pxfDisk(id);
372  is2D=true;
373  isStereo=false;
374  }
375  else if(subdet==SiStripDetId::TIB){
376 
377  layer=trackerTopology_->tibLayer(id);
379  isStereo=trackerTopology_->tibIsStereo(id);
380  }
381  else if(subdet==SiStripDetId::TID){
382 
383  layer=trackerTopology_->tidWheel(id);
385  isStereo=trackerTopology_->tidIsStereo(id);
386  }
387  else if(subdet==SiStripDetId::TOB){
388 
389  layer=trackerTopology_->tobLayer(id);
391  isStereo=trackerTopology_->tobIsStereo(id);
392  }
393  else if(subdet==SiStripDetId::TEC){
394 
395  layer=trackerTopology_->tecWheel(id);
397  isStereo=trackerTopology_->tecIsStereo(id);
398  }
399  else{
400  edm::LogError("AlignmentStats")<<"Detector not belonging neither to pixels nor to strips! Skipping it. SubDet= "<<subdet;
401  }
402 
403  //write in the hitstree
404  hitstree->Fill();
405  }//end loop over detunits
406 
407 
408  //save hitstree
409  hitstree->Write();
410  delete hitstree;
411  //delete Detunitslist;
412  hitmap_.clear();
413  overlapmap_.clear();
414  delete hitsfile;
415 }
DetHitMap hitmap_
bool tecIsDoubleSide(const DetId &id) const
bool tobIsDoubleSide(const DetId &id) const
bool tibIsDoubleSide(const DetId &id) const
unsigned int tibLayer(const DetId &id) const
bool tobIsStereo(const DetId &id) const
unsigned int pxfDisk(const DetId &id) const
DetHitMap overlapmap_
const TrackerTopology * trackerTopology_
unsigned int tidWheel(const DetId &id) const
bool tidIsStereo(const DetId &id) const
bool tecIsStereo(const DetId &id) const
bool is2D(HitType hitType)
unsigned int pxbLayer(const DetId &id) const
Definition: DetId.h:18
bool tibIsStereo(const DetId &id) const
bool tidIsDoubleSide(const DetId &id) const
std::string hitsTreeName_
unsigned int tecWheel(const DetId &id) const
unsigned int tobLayer(const DetId &id) const

Member Data Documentation

float AlignmentStats::Chi2n[MAXTRKS_]
private

Definition at line 57 of file AlignmentStats.h.

Referenced by analyze(), and beginJob().

float AlignmentStats::Eta[MAXTRKS_]
private

Definition at line 57 of file AlignmentStats.h.

Referenced by analyze(), and beginJob().

int AlignmentStats::event_
private

Definition at line 55 of file AlignmentStats.h.

Referenced by analyze(), and beginJob().

DetHitMap AlignmentStats::hitmap_
private

Definition at line 62 of file AlignmentStats.h.

Referenced by analyze(), and endJob().

std::string AlignmentStats::hitsTreeName_
private

Definition at line 46 of file AlignmentStats.h.

Referenced by endJob().

bool AlignmentStats::keepHitPopulation_
private

Definition at line 44 of file AlignmentStats.h.

bool AlignmentStats::keepTrackStats_
private

Definition at line 43 of file AlignmentStats.h.

const int AlignmentStats::MAXTRKS_ =200
staticprivate

Definition at line 54 of file AlignmentStats.h.

Referenced by analyze().

int AlignmentStats::Nhits[MAXTRKS_][7]
private

Definition at line 58 of file AlignmentStats.h.

Referenced by analyze(), and beginJob().

unsigned int AlignmentStats::ntracks
private

Definition at line 56 of file AlignmentStats.h.

Referenced by analyze(), and beginJob().

TTree* AlignmentStats::outtree_
private

Definition at line 53 of file AlignmentStats.h.

Referenced by AlignmentStats(), analyze(), beginJob(), and endJob().

edm::InputTag AlignmentStats::overlapAM_
private

Definition at line 42 of file AlignmentStats.h.

Referenced by analyze().

DetHitMap AlignmentStats::overlapmap_
private

Definition at line 63 of file AlignmentStats.h.

Referenced by analyze(), and endJob().

float AlignmentStats::P[MAXTRKS_]
private

Definition at line 57 of file AlignmentStats.h.

float AlignmentStats::Phi[MAXTRKS_]
private

Definition at line 57 of file AlignmentStats.h.

Referenced by analyze(), and beginJob().

uint32_t AlignmentStats::prescale_
private

Definition at line 47 of file AlignmentStats.h.

Referenced by analyze(), and beginJob().

float AlignmentStats::Pt[MAXTRKS_]
private

Definition at line 57 of file AlignmentStats.h.

Referenced by analyze(), and beginJob().

int AlignmentStats::run_
private

Definition at line 55 of file AlignmentStats.h.

Referenced by analyze(), and beginJob().

edm::InputTag AlignmentStats::src_
private

Definition at line 41 of file AlignmentStats.h.

Referenced by analyze().

std::string AlignmentStats::statsTreeName_
private

Definition at line 45 of file AlignmentStats.h.

Referenced by beginJob().

uint32_t AlignmentStats::tmpPresc_
private

Definition at line 49 of file AlignmentStats.h.

Referenced by analyze(), and beginJob().

const TrackerGeometry* AlignmentStats::trackerGeometry_
private

Definition at line 66 of file AlignmentStats.h.

Referenced by analyze().

const TrackerTopology* AlignmentStats::trackerTopology_
private

Definition at line 67 of file AlignmentStats.h.

Referenced by analyze(), and endJob().

TFile* AlignmentStats::treefile_
private

Definition at line 52 of file AlignmentStats.h.

Referenced by beginJob(), and endJob().